import { getExamAd } from '@/api/exam'
import tool from '@/utils/tool'
export default {
  namespaced: true,
  state: () => ({
    // 顶部banner
    // top_banners: [],
    // profession_id: '' // 目前没用,如果以后题库要分专业显示广告大概用得上.
  }),
  mutations: {
    // 设置专业id
    // setProfessionId(state, data) {
    //   state.profession_id = data
    // }
  },
  actions: {
    // 获取头部广告
    async getExamAd({ commit, state, rootState }, params) {
      // let { profession_id } = params
      // commit('setProfessionId', profession_id || '')
      let res = await getExamAd(params).catch(err => {
        return { data: {} }
      })
      // 设置topbanner
      rootState.activity_banner =
        (Array.isArray(res.data) &&
          tool.encodeString({ ...res.data[0], element_name: 12 })) ||
        {}
    }
  },
  getters: {}
}
